#include "DragFelyne.h"

DragFelyne::DragFelyne(const QString& gifPath, QWidget* parent) : QLabel(parent) {
    QMovie* movie = new QMovie(gifPath, {}, this);
    setMovie(movie);
    movie->start();
    setMouseTracking(true);
}

void DragFelyne::mousePressEvent(QMouseEvent* event) {
    if (event->button() == Qt::LeftButton) {
        dragPos = event->pos();
    }
}

void DragFelyne::mouseMoveEvent(QMouseEvent* event) {
    if (event->buttons() & Qt::LeftButton) {
        QPoint delta = event->pos() - dragPos;
        this->move(this->pos()+delta);
    }
}
void DragFelyne::mouseReleaseEvent(QMouseEvent *event) {
    releasePos = mapTo(parentWidget(), event->pos());
    // qDebug() << "Mouse released at:" << releasePos;
    emit released();
}
